<template>
  <div class="contain">
    <div class="center">
      <div class="cen-lef" @click="goHome">
        <img src="../../assets/imgs/logo.png" />
        <span>尚医通&nbsp;预约挂号统一平台</span>
      </div>
      <div class="cen-rig">
        <span>帮助中心</span>
        <span @click="goLogin" v-if="!isLogin()">登录/注册</span>
        <el-dropdown class="dropdown-box" v-else>
          <span class="el-dropdown-link">
            {{ UserName }}
            <el-icon class="el-icon--right">
              <arrow-down />
            </el-icon>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item @click="goIdentify">实名认证</el-dropdown-item>
              <el-dropdown-item @click="goOrder">挂号订单</el-dropdown-item>
              <el-dropdown-item @click="goPatient">就诊人管理</el-dropdown-item>
              <el-dropdown-item @click="outLogin">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>

<script>
import { isLogin, removeLogin } from "@/utils/userInfo";
export default {
  name: "HospitalTop",
  data() {
    return {
      dialogVisible: false,
    };
  },
  methods: {
    goLogin() {
      this.dialogVisible = true;
      this.$store.commit("user/GET_DIALOG", this.dialogVisible);
    },
    outLogin() {
      removeLogin();
      this.$router.push("/home");
    },
    goIdentify() {
      this.$router.push({ path: "/user/cetificationPage" });
    },
    goOrder() {
      this.$router.push({ path: "/user/orderPage" });
    },
    goPatient() {
      this.$router.push({ path: "/user/patientPage" });
    },
    goHome() {
      this.$router.push({ path: "/" });
    },
    isLogin,
  },
  computed: {
    UserName() {
      if (localStorage.getItem("name")) {
        return localStorage.getItem("name");
      } else {
        return "";
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.contain {
  height: 70px;
  width: 100%;
  position: fixed;
  top: 0;
  background-color: #fff;
  z-index: 10;
  .center {
    width: 1200px;
    height: 100%;
    display: flex;
    margin: 0 auto;
    align-items: center;
    justify-content: space-between;
    .cen-lef {
      height: 100%;
      display: flex;
      align-items: center;
      img {
        height: 80%;
        margin-right: 10px;
      }
      span {
        font-size: 20px;
        color: #55a6fe;
      }
    }
    .cen-rig {
      font-size: 14px;
      color: #bbbbbb;
      :first-child {
        margin-right: 10px;
      }
      .dropdown-box :focus {
        outline: 0;
      }
    }
  }
}
</style>
